import { useEffect, useState } from "react";


// 自定义hooks
function useData() {

    const [data, setData] = useState([]);

    //当组件已加载
    useEffect(() => {
        fetch('/mock/hero.json').then(res => res.json()).then(res => {
            setData(res)
        })
    }, [])

    return {
        data,
        setData
    }

}

export default useData;